package leetcode.动态规划;

public class 使字符串平衡的最小删除次数1653 {
    public int minimumDeletions(String s) {
        int count = 0,dp = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if(c == 'a')
                dp = Math.min(dp+1,count);
            else
                ++count;
        }
        return dp;
    }

    public static void main(String[] args) {
        new 使字符串平衡的最小删除次数1653().minimumDeletions("aababbab");
    }
}
